import $url from '/shop/url/index.js';
import $user from '/shop/store/user.js';
import $app from '/shop/store/app.js';
import $third from '/shop/api/third.js';
import {
	formatImageUrlProtocol
} from './index';

const user = async (poster) => {
	const width = poster.width;
	console.log('---sssccc----: ', $url.cdn($app().platform.share.posterInfo.user_bg));
	const userInfo = $user().userInfo;
	console.log('poster.shareInfo.path: ------>   ', poster.shareInfo.path);
	const {
		data
	} = await $third.wechat.getWxacode({
		"platform": "min",
		"path": poster.shareInfo.path
	});
	// console.log("$url.cdn($app().platform.share.posterInfo.user_bg---->  ", $url.cdn($app().platform.share.posterInfo.user_bg)
	return {
		background: formatImageUrlProtocol($url.cdn($app().platform.share.posterInfo.user_bg)),
		list: [{
				name: 'nickname',
				type: 'text',
				val: userInfo.nickname,
				x: width / 2,
				y: width * 0.4,
				paintbrushProps: {
					textAlign: 'center',
					fillStyle: '#333',
					font: {
						fontSize: 14,
						fontFamily: 'sans-serif',
					},
				},
			},
			{
				name: 'avatar',
				type: 'image',
				val: formatImageUrlProtocol($url.cdn(userInfo.avatar)),
				x: width * 0.4,
				y: width * 0.16,
				width: width * 0.2,
				height: width * 0.2,
				d: width * 0.2,
			},
			// #ifndef MP-WEIXIN
			{
				name: 'qrcode',
				type: 'qrcode',
				val: poster.shareInfo.link,
				x: width * 0.35,
				y: width * 0.84,
				size: width * 0.3,
			},
			// #endif
			// #ifdef MP-WEIXIN
			{
				name: 'wxacode',
				type: 'image',
				// val: $third.wechat.getWxacode(poster.shareInfo.path),
				val: formatImageUrlProtocol($url.cdn(data)),
				x: width * 0.35,
				y: width * 0.84,
				width: width * 0.3,
				height: width * 0.3,
			},
			// #endif
		],
	};
};

export default user;